home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.hitl.washington.edu
/
ftp.hitl.washington.edu.tar
/
ftp.hitl.washington.edu
/
pub
/
people
/
tsoper
/
My Sample Apps
/
OpenGLApp
/
OpenGLPanel.cs
< prev
Wrap
Text File
|
2005-05-08
|
2KB
|
70 lines
using System;
using System.Drawing;
using System.Windows.Forms;
using CsGL.OpenGL;
class AnotherForm : Form
{
View view = new View();
private System.Windows.Forms.Panel panel;
public AnotherForm(Form parentForm)
{
this.Text = "Another Form";
this.MdiParent = parentForm;
this.panel = new System.Windows.Forms.Panel();
this.panel.Controls.AddRange(
new System.Windows.Forms.Control[] { view });
this.Controls.AddRange(
new System.Windows.Forms.Control[] {this.panel });
panel.BorderStyle = BorderStyle.Fixed3D;
view.Dock = DockStyle.Fill;
this.panel.Dock = DockStyle.Fill;
this.Dock = DockStyle.Fill;
this.TopMost = true;
this.Show();
}
}
class View : OpenGLControl
{
public override void glDraw()
{
GL.glClear( GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT ); // Clear Screen And Depth Buffer
GL.glBegin( GL.GL_POINTS );
GL.glVertex2i( 100, 50 );
GL.glVertex2i( 100, 130 );
GL.glVertex2i( 150, 130 );
GL.glEnd();
GL.glFlush();
}
protected override void InitGLContext()
{
GL.glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
GL.glColor3f( 1.0f, 0.0f, 0.0f );
GL.glPointSize( 4.0f );
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
GL.glMatrixMode(GL.GL_PROJECTION);
GL.glLoadIdentity();
GL.gluOrtho2D( 0.0, Size.Width, 0.0, Size.Height );
}
}
class SampleApp
{
static void Main()
{
Form form = new SampleForm();
Application.Run(form);
}
}